package com.sc.VenusQueryBeta.presenter.setting.change;

import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.setting.change.ChangeContract;
import com.sc.VenusQueryBeta.model.bean.home.ChangeNextBean;
import com.sc.VenusQueryBeta.model.setting.change.ChangeModel;

import io.reactivex.functions.Consumer;

/**
 * Created by SC-02 on 2018/9/19.
 * 修改密码presenter 继承契约类的presenper
 */

public class ChangePresenter extends ChangeContract.ChangePresenter{

    @Override
    protected ChangeContract.IChangeModel getModel() {
        return ChangeModel.newInstance();
    }

    @Override
    public void onStart() {

    }
    /**
     * 实例化对象提供给外界
     */
    public static ChangePresenter newInstance(){
        return new ChangePresenter();
    }

    @Override
    public void changeNext(String oldPassword, String newPassword, int registerIndex, String loginUserId) {
        mRxManager.register(mIModel.changenext(oldPassword,newPassword,registerIndex,loginUserId).subscribe(new Consumer<ChangeNextBean>() {
            @Override
            public void accept(ChangeNextBean changeNextBean) throws Exception {
                //   LogUtils.e("是这里报错hhhhh");
                if (mIView != null)
                    mIView.showChangeNextSuccess(changeNextBean);
                LogUtils.e("是这里报错hhhhh");

            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                // LogUtils.e("是这里报错");
                if (mIView != null)
                    //  mIView.showToast("Network error.33");
                    mIView.showNetworkError();
                LogUtils.e("是这里报错");
            }
        }));
    }
}
